package com.feihong.txgw.tx_model;

import com.feihong.txgw.http.Host;
import com.feihong.txgw.http.HttpTools;
import com.feihong.txgw.inter.contract.kaika.IKaikaSubmitContract;
import com.feihong.txgw.utils.helper.RxHelper;
import com.feihong.txgw.utils.manage.RetrofitManager;
import com.feihong.txgw.utils.sign.SignToken;

import java.util.HashMap;
import java.util.Map;

import io.reactivex.Observable;
import okhttp3.MultipartBody;

/**
 * @Author wangziheng
 * @ProjectName txgw_app
 * @ClassName KaikaSubmitMainModel
 * @package com.feihong.txgw.tx_model
 * @data 2018/5/4 17:00
 * @Describe
 * @Change
 */
public class KaikaSubmitMainModel implements IKaikaSubmitContract.IKaikaSubmitMainModel {

    public static KaikaSubmitMainModel create(){
        return new KaikaSubmitMainModel();
    }
    @Override
    public Observable<String> submitNormaoOrder(HashMap<String, String> mParams) {
        Map<String,String> newParams = mParams;
        Map<String,String> mSignParams = new SignToken().setSigen(newParams);
        return RetrofitManager.getInstance()
                .<String>txgwRequest(Host.HTTP_HOME + "App/Orderphonenum/order",
                mSignParams.get(SignToken.sSign),
                mSignParams.get(SignToken.sToken),
                mSignParams.get(SignToken.sData),
                mSignParams.get(SignToken.sVersion))
                .compose(RxHelper.<String>rxSchedulerHelper());
    }

    @Override
    public Observable<String> kaikaAuthResult(String json) {
        Map<String,String> mParams = new HashMap<>();
        mParams.put("json_data",json);
        return RetrofitManager.getInstance().kaikaAutoIDCard(mParams).compose(RxHelper.<String>rxSchedulerHelper());
    }

    @Override
    public Observable<String> submitYuyueOrder(HashMap<String, String> mParams) {
        Map<String,String> newParams = mParams;
        Map<String,String> mSignParams = new SignToken().setSigen(newParams);
        return RetrofitManager.getInstance()
                .<String>txgwRequest(HttpTools.HTTP_HOME + "App/Orderphonenum/yuyue_order"
                        ,mSignParams.get(SignToken.sSign),
                        mSignParams.get(SignToken.sToken),
                        mSignParams.get(SignToken.sData),
                        mSignParams.get(SignToken.sVersion))
                .compose(RxHelper.<String>rxSchedulerHelper());
    }

    @Override
    public Observable<String> kaikaUploadIDCardImg(MultipartBody.Part file) {
        return RetrofitManager.getInstance().kaikaUploadIDCardImg(file).compose(RxHelper.<String>rxSchedulerHelper());
    }


}
